Skip to content

fix: maturin build --sdist wheel name/layout for excluded workspace crates#3031

Merged
messense merged 1 commit into
PyO3:mainfrom
messense:fix/sdist-excluded-workspace-layout
Feb 23, 2026
Merged

fix: maturin build --sdist wheel name/layout for excluded workspace crates#3031
messense merged 1 commit into
PyO3:mainfrom
messense:fix/sdist-excluded-workspace-layout

Conversation

@messense

Copy link
Copy Markdown
Member

When a crate is excluded from its Cargo workspace and has path dependencies outside its directory, the sdist places pyproject.toml at the sdist root while the Cargo.toml lives in a subdirectory. After unpacking, resolve_manifest_paths walks up from the Cargo.toml but stops at the cargo workspace boundary (which for an excluded crate is the crate's own directory), never reaching the pyproject.toml. This caused module-name, project name, and python-source to be lost, producing wheels with the wrong name and missing python files.

Fix by threading the known pyproject.toml path from unpack_sdist through BuildContextBuilder into ProjectResolver::resolve, so the discovery walk is skipped when the path is already known.

Also canonicalize the unpacked sdist directory to resolve symlinks (e.g. /var -> /private/var on macOS), which otherwise causes project_root and python_dir to disagree after normalize(), silently excluding python source files from wheels.

Closes #3030

… crates

When a crate is excluded from its Cargo workspace and has path
dependencies outside its directory, the sdist places pyproject.toml at
the sdist root while the Cargo.toml lives in a subdirectory.  After
unpacking, `resolve_manifest_paths` walks up from the Cargo.toml but
stops at the cargo workspace boundary (which for an excluded crate is
the crate's own directory), never reaching the pyproject.toml.  This
caused module-name, project name, and python-source to be lost,
producing wheels with the wrong name and missing python files.

Fix by threading the known pyproject.toml path from `unpack_sdist`
through `BuildContextBuilder` into `ProjectResolver::resolve`, so
the discovery walk is skipped when the path is already known.

Also canonicalize the unpacked sdist directory to resolve symlinks
(e.g. /var -> /private/var on macOS), which otherwise causes
`project_root` and `python_dir` to disagree after `normalize()`,
silently excluding python source files from wheels.

Closes PyO3#3030
@messense messense merged commit 307a442 into PyO3:main Feb 23, 2026
45 checks passed
@messense messense deleted the fix/sdist-excluded-workspace-layout branch February 23, 2026 10:48
bmwiedemann pushed a commit to bmwiedemann/openSUSE that referenced this pull request Mar 31, 2026
https://build.opensuse.org/request/show/1343551
by user mia + anag_factory
- Drop CVE-2026-25727.patch (handled in _service)
- Update to 1.12.6
  * Sync legacy_py.rs with upstream PyPI warehouse legacy.py
    gh#PyO3/maturin#3053
  * Keep cargo build artifact at original path after staging
    gh#PyO3/maturin#3054
- Update to 1.12.5
  * feat: include debug info files (.pdb, .dSYM, .dwp) in wheels
    gh#PyO3/maturin#3024
  * Fix wrong abi3 tag for conditional cargo features enabled pyo3
    abi3 feature
    gh#PyO3/maturin#3029
  * fix: maturin build --sdist wheel name/layout for excluded
    workspace crates
    gh#PyO3/maturin#3031
  * fix: preserve wheel output dir when building from unpacked
    sdist
    gh#PyO3/maturin#3036
  * feat: add python-implementation condition to conditional
    features
    gh#PyO3/maturin#3038
  * Fix non-existent comment tag
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

maturin build --sdist behavior change in 1.12.3+ (works in 1.12.2)

1 participant